<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设置 - 数独求解器</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
    <div class="container mx-auto px-4 py-8 max-w-3xl">
        <h1 class="text-4xl font-bold text-center text-gray-800 mb-10 pt-6">设置</h1>
        
        <div class="bg-white rounded-xl shadow-xl p-8 mb-8">
            <div class="mb-8">
                <div class="flex justify-between items-center">
                    <h2 class="text-2xl font-semibold text-gray-800 border-b-2 border-gray-200 pb-3">OCR引擎选择</h2>
                    <button id="back-btn" class="px-4 py-2 bg-gradient-to-r from-gray-600 to-slate-700 text-white rounded-lg hover:from-gray-700 hover:to-slate-800 transition-all shadow-md font-medium">返回</button>
                </div>
                <div class="space-y-5 mt-6">
                    <div class="flex items-center p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition">
                        <input type="radio" id="opencv" name="ocr-engine" value="opencv" class="w-5 h-5 text-blue-600 mr-4" checked>
                        <label for="opencv" class="text-xl font-medium text-gray-700">OpenCV OCR <span class="text-gray-500 font-normal">(默认，离线识别)</span></label>
                    </div>
                    <div class="flex items-center p-4 bg-gray-50 rounded-lg hover:bg-gray-100 transition">
                        <input type="radio" id="tesseract" name="ocr-engine" value="tesseract" class="w-5 h-5 text-blue-600 mr-4">
                        <label for="tesseract" class="text-xl font-medium text-gray-700">Tesseract.js <span class="text-gray-500 font-normal">(在线识别，精度更高)</span></label>
                    </div>
                </div>
            </div>
            
            <div id="tesseract-settings-container" class="hidden mb-10">
                <div id="tesseract-settings-header" class="flex justify-between items-center cursor-pointer text-2xl font-semibold mb-6 text-gray-800 border-b-2 border-gray-200 pb-3">
                    <h2>Tesseract配置</h2>
                    <i id="toggle-icon" class="fas fa-chevron-down transition-transform duration-300"></i>
                </div>
                <div id="tesseract-settings-content" class="hidden">
                    <div class="bg-amber-50 border-l-4 border-amber-500 p-5 mb-6 rounded-r-lg">
                        <p class="text-amber-700">
                            <strong>重要说明：</strong>Tesseract需要在本地安装才能正常工作。
                        </p>
                    </div>
                    <div class="space-y-6">
                        <div>
                            <label for="tesseract-cmd" class="block text-gray-700 text-lg mb-3">Tesseract命令路径</label>
                            <input type="text" id="tesseract-cmd" class="w-full px-4 py-3 text-lg border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="请输入Tesseract命令路径">
                        </div>
                        <div class="bg-blue-50 border-l-4 border-blue-500 p-4 rounded-r-lg">
                            <h3 class="font-semibold text-blue-800 mb-2">配置步骤：</h3>
                            <ol class="list-decimal list-inside text-blue-700 space-y-1">
                                <li>安装Tesseract OCR引擎</li>
                                <li>获取Tesseract可执行文件路径</li>
                                <li>将路径填入上方输入框</li>
                                <li>点击"保存设置"按钮</li>
                            </ol>
                        </div>
                        <button id="save-tesseract" class="px-6 py-3 bg-gradient-to-r from-blue-500 to-sky-600 text-white text-lg rounded-lg hover:from-blue-600 hover:to-sky-700 transition-all shadow-md font-medium">保存配置</button>
                    </div>
                </div>
            </div>
            
            <div id="statusMessage" class="status-message hidden mb-4 p-4 rounded-lg text-left"></div>
            
            <div class="flex justify-end pt-6">
                <button id="save-settings" class="px-6 py-3 bg-gradient-to-r from-green-500 to-emerald-600 text-white rounded-lg hover:from-green-600 hover:to-emerald-700 transition-all shadow-md font-medium">保存设置</button>
            </div>
        </div>
    </div>
    
    <script src="settings.js"></script>
</body>
</html>